<ui-tabset>
    <ui-tab select="adv.currentType = 'autoScale'">
        <ui-tab-heading>自动伸缩</ui-tab-heading>
        <form name="adv.autoScaleForm" class="form-horizontal service-autoScale-form" novalidate>
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">是否启用</label>
                        <div class="col-sm-8" style="padding-top: 7px">
                            <ctg-switch ng-model="adv.atsCheck"></ctg-switch>
                        </div>
                    </div>
                </div>
            </div>
            <div ng-switch="adv.atsTarget" ng-if="adv.atsCheck">
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group" ng-class="{'has-error': (adv.autoScaleForm.atsTarget.$touched || adv.autoScaleForm.$submitted )
                     && adv.autoScaleForm.atsTarget.$error.required}">
                            <label for="atsTarget" class="col-sm-4 control-label">指标</label>
                            <div class="col-sm-8">
                                <select ng-model="adv.atsTarget" class="form-control" name="atsTarget" id="atsTarget" required>
                                    <option value="">请选择指标</option>
                                    <option value="002">CPU使用量</option>
                                    <option value="001">时间周期</option>
                                </select>

                                <div class="text-danger" ng-show="(adv.autoScaleForm.atsTarget.$touched || adv.autoScaleForm.$submitted )
                         && adv.autoScaleForm.atsTarget.$error.required">请选择指标
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group" ng-class="{'has-error': (adv.autoScaleForm.minPodNum.$touched || adv.autoScaleForm.$submitted )
                     && (adv.autoScaleForm.minPodNum.$error.pattern || adv.autoScaleForm.minPodNum.$error.required
                     || adv.autoScaleForm.minPodNum.$error.number)}">
                            <label for="minPodNum" class="col-sm-4 control-label">最小容器数</label>
                            <div class="col-sm-8">
                                <input type="number" ng-model="adv.minPodNum" ng-pattern="/^\d+$/"
                                       class="form-control" name="minPodNum" id="minPodNum" placeholder="请输入最小容器数"
                                       required/>

                                <div class="text-danger"
                                     ng-show="(adv.autoScaleForm.minPodNum.$touched || adv.autoScaleForm.$submitted)">
                                    {{((adv.autoScaleForm.minPodNum.$error.pattern || adv.autoScaleForm.minPodNum.$error.required
                                    || adv.autoScaleForm.minPodNum.$error.number) && '请输入有效的最小容器数') || ''}}
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group" ng-class="{'has-error': (adv.autoScaleForm.maxPodNum.$touched || adv.autoScaleForm.$submitted )
                     && (adv.autoScaleForm.maxPodNum.$error.pattern || adv.autoScaleForm.maxPodNum.$error.required
                     || adv.autoScaleForm.maxPodNum.$error.min || adv.autoScaleForm.maxPodNum.$error.number)}">
                            <label for="maxPodNum" class="col-sm-4 control-label">最大容器数</label>
                            <div class="col-sm-8">
                                <input type="number" ng-model="adv.maxPodNum" ng-pattern="/^\d+$/" ng-min="+adv.minPodNum+1"
                                       class="form-control" name="maxPodNum" id="maxPodNum" placeholder="请输入最大容器数"
                                       required/>

                                <div class="text-danger"
                                     ng-show="(adv.autoScaleForm.maxPodNum.$touched || adv.autoScaleForm.$submitted)">
                                    {{((adv.autoScaleForm.maxPodNum.$error.pattern || adv.autoScaleForm.maxPodNum.$error.required
                                    || adv.autoScaleForm.maxPodNum.$error.number) && '请输入有效的最大容器数')
                                    || (adv.autoScaleForm.maxPodNum.$error.min && '最大容器数必须大于默认分配的容器数') || ''}}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div ng-switch-when="002" class="row">
                    <div class="col-md-6">
                        <div class="form-group" ng-class="{'has-error': (adv.autoScaleForm.atsLimit.$touched || adv.autoScaleForm.$submitted )
                             && (adv.autoScaleForm.atsLimit.$error.required || adv.autoScaleForm.atsLimit.$error.number
                             || adv.autoScaleForm.atsLimit.$error.max || adv.autoScaleForm.atsLimit.$error.min)}">
                            <label for="atsLimit" class="col-sm-4 control-label">阈值</label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    <input type="number" min="50" max="100" ng-model="adv.atsLimit" name="atsLimit"
                                           id="atsLimit" class="form-control" placeholder="请输入上限值" required>
                                    <span class="input-group-addon">%</span>
                                </div>
                                <div class="text-danger" ng-show="(adv.autoScaleForm.atsLimit.$touched || adv.autoScaleForm.$submitted )
                             && (adv.autoScaleForm.atsLimit.$error.required || adv.autoScaleForm.atsLimit.$error.number
                             || adv.autoScaleForm.atsLimit.$error.max || adv.autoScaleForm.atsLimit.$error.min)">请输入有效的阈值
                                    (50%~100%)
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div ng-switch-when="001">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group" ng-class="{'has-error': (adv.autoScaleForm.startTime.$touched || adv.autoScaleForm.$submitted )
                                    && !adv.atsStartTime}">
                                <label for="startTime" class="col-sm-4 control-label">开始时间</label>
                                <div class="col-sm-8">
                                    <div class="input-group">
                                        <input id="startTime" name="startTime" id="startTime" min-Date="adv.atsMinDate"
                                               maxlength="50"
                                               class="form-control" ui-datepicker-popup type="text" ng-model="adv.atsStartTime"
                                               view="datetime" format="yyyy-MM-dd HH:mm:ss" placeholder="请选择开始时间" required/>
                                        <span class="input-group-addon">{{adv.atsStartDayOfWeek}}</span>
                                    </div>
                                    <div class="text-danger" ng-show="(adv.autoScaleForm.startTime.$touched || adv.autoScaleForm.$submitted )
                                    && !adv.atsStartTime">请选择开始时间
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group" ng-class="{'has-error': (adv.autoScaleForm.endTime.$touched || adv.autoScaleForm.$submitted )
                                    && !adv.atsEndTime}">
                                <label for="endTime" class="col-sm-4 control-label">结束时间</label>
                                <div class="col-sm-8">
                                    <div class="input-group">
                                        <input id="endTime" name="endTime" id="endTime" min-Date="adv.atsMinDate" maxlength="50"
                                               class="form-control" ui-datepicker-popup type="text" ng-model="adv.atsEndTime"
                                               view="datetime" format="yyyy-MM-dd HH:mm:ss" placeholder="请选择结束时间" required/>
                                        <span class="input-group-addon">{{adv.atsEndDayOfWeek}}</span>
                                    </div>
                                    <div class="text-danger" ng-show="(adv.autoScaleForm.endTime.$touched || adv.autoScaleForm.$submitted )
                                    && !adv.atsEndTime">请选择结束时间
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">重复</label>
                        <div class="col-sm-10">
                            <div class="input-group">
                                <select class="form-control" ng-model="adv.atsSpace"
                                        ng-change="adv.spaceChange(adv.atsStartTime);adv.setSpaceInst(adv.atsStartTime,adv.atsEndTime)"
                                        ng-options="opt.val as opt.desc for opt in adv.atsSpaceOpts">
                                </select>
                                <span class="input-group-addon">{{adv.atsSpaceInst}}</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </ui-tab>
    <ui-tab select="adv.currentType = 'domain'">
        <ui-tab-heading>域名管理</ui-tab-heading>
        <form name="adv.domainForm" class="form-horizontal" novalidate>
            <div class="form-group" ng-class="{'has-error': (adv.domainForm.podDomain.$touched || adv.domainForm.$submitted )
                     && adv.domainForm.podDomain.$error.pattern}">
                <label for="podDomain" class="col-sm-2 control-label">域名</label>
                <div class="col-sm-10">
                    <input class="form-control" id="podDomain" name="podDomain" ng-model="adv.podDomain"
                           ng-pattern="/^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/"/>
                    <div class="text-danger" ng-show="(adv.domainForm.podDomain.$touched || adv.domainForm.$submitted )
                         && adv.domainForm.podDomain.$error.pattern">请输入有效域名
                    </div>
                </div>
            </div>
        </form>
    </ui-tab>
</ui-tabset>
